package com.bookShop.action;

import java.util.ArrayList;
import java.util.List;

import com.bookShop.dao.impl.BookOrderDao;
import com.bookShop.entity.BookOrder;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AdminOrderAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	private BookOrder bo;
	private int id;
	private BookOrderDao bod;
	
	public AdminOrderAction() {
		bod = new BookOrderDao();
	}

	
	public BookOrder getBookorder() {
		return bo;
	}


	public void setBookorder(BookOrder bookorder) {
		this.bo = bookorder;
	}


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String selectOrder() throws Exception {
		List<BookOrder> bookorders = new ArrayList<BookOrder>();
		bookorders = bod.selectAll();
		ActionContext.getContext().getSession().put("ADMINORDER", bookorders);
		return SUCCESS;
	}
	
	public String updataOrder() throws Exception{
		bod.updata(id);
		return SUCCESS;
	}
	public String deleteOrder() throws Exception{
		bod.delete(id);
		return SUCCESS;
	}
	
	public String selectMyOrder()throws Exception{
		List<BookOrder> myorder = new ArrayList<BookOrder>();
		myorder =bod.selectMyOrder(id);
		ActionContext.getContext().getSession().put("MYORDER", myorder);
		return SUCCESS;
	}
}
